package base.day06;

import java.util.Random;

public class Stydy8 {
    public static void main(String[] args) {
        //生成10个1-100之间的随机数,将其存入数组中
        //1，求所有数据和
        //2，求所有数平均数
        //3，统计有多少个数比平均数小
        int[] array = new int[100];
        for (int i = 0; i < 100; i++) {
            Random rd = new Random();
            int number = rd.nextInt(100);
            array[i] = number;
        }
        int sum = 0;
        for (int i = 0; i < 100; i++) {
            sum += array[i];
        }
        System.out.println("数组中所有数据和是：" + sum);
        System.out.println("平均数是：" + sum / 100);
        int count = 0;
        for (int i = 0; i < 100; i++) {
            if (array[i] < (sum / 100)) {
                count += 1;
            }
        }
        System.out.println("小于平均数的元素一共有" + count + "个");

    }
}
